<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
	<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<base href="${BaseContext }">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<!-- 引入bootstrap -->
	<link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="static/css/bootstrap-select.css">
	<!-- 引入JQuery  bootstrap.js-->
	<script src="static/js/jquery-3.2.1.min.js"></script>
	<script src="static/js/bootstrap.min.js"></script>
	<script src="static/js/bootstrap-select.js"></script>
	<script src="static/js/defaults-zh_CN.js"></script>
</head>
<body>
	<!-- 顶栏  -->
	<jsp:include page="include/top.jsp"></jsp:include>
	<!-- 菜单 -->
	<%-- <jsp:include page="menu.jsp"></jsp:include> --%>	
	<!-- 中间主体 -->
	<div class="container" id="content">
		<div class="row">
			<!-- 菜单 -->
			<jsp:include page="include/menu.jsp"></jsp:include>
			<div class="col-md-10">
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="row">
							<h3 class="col-md-5">评估安排</h3>
							<!-- 按照学院查询教师 -->
							<form class="bs-example bs-example-form col-md-4" id="gradeForm" role="form" style="margin: 20px 0 10px 0;" action="admin/manageAssessPlan.do" method="post">
								<select class="selectpicker" id="grade-select" name="tGrade">
									<option value="0">---请选择院系---</option>
									<c:forEach items="${gradeModels }" var="grade">
										<option value="${grade.gId }" <c:if test="${tGrade==grade.gId}">selected</c:if>>${grade.gName }</option>
									</c:forEach>
								</select>
							</form>
								<button class="btn btn-default col-md-1" style="margin-top: 20px" onclick="selectByGrade()">
									搜索
								</button>
							
							<!-- 翻页form -->
							<form id="hiddenForm" action="admin/manageAssessPlan.do"
								method="post">
								<input type="hidden" name="pageNum" id="pageNum">
								<input type="hidden" name="tGrade" value="${tGrade}">
							</form>
						</div>
					</div>
					<table class="table table-bordered">
						<thead>
							<tr>
								<th>教师编号</th>
								<th>姓名</th>
								<th>性别</th>
								<th>出生年份</th>
								<th>学历</th>
								<th>职称</th>
								<th>学院</th>
								<th>状态</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${pageInfo.list}" var="teacher">
								<tr>
									<td>${teacher.tId}</td>
									<td>${teacher.tName}</td>
									<td><c:if test="${teacher.tSex==0 }">男</c:if> <c:if
											test="${teacher.tSex==1 }">女</c:if></td>
									<td><fmt:formatDate value="${teacher.tBirth}"
											dateStyle="medium" /></td>
									<td><c:if test="${teacher.tDgree==0 }">本科</c:if> <c:if
											test="${teacher.tDgree==1 }">硕士</c:if> <c:if
											test="${teacher.tDgree==2 }">博士</c:if></td>
									<td><c:if test="${teacher.tTitle==0 }">教师</c:if> <c:if
											test="${teacher.tTitle==1 }">助教</c:if> <c:if
											test="${teacher.tTitle==2 }">副教授</c:if> <c:if
											test="${teacher.tTitle==3 }">教授</c:if></td>
									<td>${teacher.gradeModel.gName}</td>
									<td><c:if test="${teacher.assessStatus==0 }">未评估</c:if> <c:if
											test="${teacher.assessStatus==1 }">评估中</c:if> <c:if
											test="${teacher.assessStatus==2 }">已评估</c:if></td>
									<td><c:if test="${teacher.assessStatus==0 }">
											<button class="btn btn-default btn-xs btn-info"
												tid="${teacher.tId}" tname="${teacher.tName}"
												tgrade="${teacher.gradeModel.gName}"
												onClick="openModal(this);">安排考评</button>
										</c:if> <c:if test="${teacher.assessStatus!=0 }">
											<button
												class="btn btn-default btn-xs btn-warning btn-primary"
												onClick="checkAssess(${teacher.tId})">查看进度</button>
										</c:if> 
										
										<!--弹出框--></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				<!-- 页码 -->
				<jsp:include page="include/pageInfo.jsp"></jsp:include>

				<!-- 评教安排modal -->
				<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
					<div class="modal-dialog" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>
								<h3 class="modal-title" id="modal-title"></h3>
								<hr>
								<div class="row">
									<div class="col-md-8">
										<h4>教师信息</h4>
									</div>
								</div>
								<div class="row">
									<div class="col-md-4">
										教师编号 ：<span id="row-tid"></span>
									</div>
									<div class="col-md-4">
										教师姓名 ： <span id="row-tname"></span>
									</div>
									<div class="col-md-4">
										所属学院 ： <span id="row-tgrade"></span>
									</div>
								</div>
							</div>
							<div class="modal-body">
								<div class="modal-body" id="modal-body"></div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-primary" id="next-btn">下一步</button>
							</div>
						</div>
					</div>
				</div>
				<!-- 查看评教进度modal -->
				<div class="modal fade" id="planModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
					<div class="modal-dialog" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>
								<h3 class="modal-title" id="assess-title"></h3>
							</div>
							<div class="modal-body">
								<div class="modal-body" id="assess-body"></div>
							</div>
						</div>
					</div>
				</div>
				
			</div>
		</div>
	</div>
	<!-- footer -->
	<jsp:include page="include/footer.jsp"></jsp:include>
</body>
	<script type="text/javascript">
		$("#nav li:nth-child(5)").addClass("active")
        /* 翻页按钮 */
        function goPage(page){
			$("#pageNum").val(page);
			$("#hiddenForm").submit();
		}
		/* 搜索按钮 */
		function selectByGrade(){
			/*alert($('#gradeForm').serialize());*/
			$("#gradeForm").submit();
		}
		/*打开模态框*/
		function openModal(obj){
			var tId = $(obj).attr('tid');
			var tName = $(obj).attr('tname');
			var tGrade = $(obj).attr('tgrade');
			$('#row-tid').html(tId);
			$('#row-tname').html(tName);
			$('#row-tgrade').html(tGrade);
			$('#modal-title').html('选择专家列表');
			$('#exampleModal').modal('toggle');
			getProfessors();
		}
		/*选择评教专家*/
		function getProfessors(){
			$('#modal-body').html('');
			$('#modal-body').load('admin/getProfessors.do');
		}
		/*获得专家信息*/
		function getProfessor(pid,tid){
			$('#modal-body').html('');
			$('#modal-body').load('admin/getProfessor.do?pid='+pid+'&tid='+tid);
		}
        
        $(function(){
	        /*下一步按钮*/
			$('#next-btn').on('click',function(){
				if($(this).attr('pid')==null){
					alert('请选择评教专家，再进行下一步操作');
				}else{
					//确认评教安排信息
					$('#modal-title').html('确认评教安排信息');
					$('#next-btn').attr('id','confirm-btn');
					$('#confirm-btn').html('确认');
					getProfessor($(this).attr('pid'),$('#row-tid').html());
					/*确认评教安排*/
					$('#confirm-btn').on('click',function(){
						if(confirm('确定此评估安排！！！')){
							$('#assessPlan-form').submit();
						}
					});
				}
			});
        });
        /* 查看评估进度 */
        function checkAssess(tid){
        	$('#assess-title').html('查看评估进度');
			$('#assess-body').html('');
			$('#assess-body').load('admin/checkAssessSchedule.do?tid='+tid);
			$('#planModal').modal('toggle');
        }
	</script>
</html>